﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Derbster.Domain
{
    [ContractClass(typeof(LeagueRepositoryContracts))]
    public interface ILeagueRepository : IQueryable<League>
    {
        League Create(string name);
        League Create(string name, string location);
        League FindById(int leagueId);
        League FindByName(string leagueName);
        League Update(League league);
        void Delete(League league);
    }

    [ContractClassFor(typeof(ILeagueRepository))]
    public abstract class LeagueRepositoryContracts : ILeagueRepository
    {
        public IEnumerator<League> GetEnumerator()
        {
            return null;
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public Expression Expression
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public Type ElementType
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public IQueryProvider Provider
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public League Create(string name)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(name));
            Contract.Ensures(Contract.Result<League>().LeagueId > 0);
            return null;
        }

        public League Create(string name, string location)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(name));
            Contract.Ensures(Contract.Result<League>().LeagueId > 0);
            return null;
        }

        public League FindById(int leagueId)
        {
            Contract.Requires(leagueId > 0);
            return null;
        }

        public League FindByName(string leagueName)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(leagueName));
            return null;
        }

        public League Update(League league)
        {
            Contract.Requires(league != null);
            Contract.Requires(league.LeagueId > 0);
            return null;
        }

        public void Delete(League league)
        {
            Contract.Requires(league != null);
            Contract.Requires(league.LeagueId > 0);
        }
    }
}
